package top.dark.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.dark.dao.beetlsql.UserDao;
import top.dark.dao.product.AttrDao;
import top.dark.dao.product.PUserDao;
import top.dark.pojo.AttrEntity;
import top.dark.pojo.UserEntity;
import top.dark.service.AttrService;
import top.dark.service.UserService;

/**
 * Author: Lijiao
 * description:
 * Create Time: 2021/5/13 14:40
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Autowired
    private PUserDao pUserDao;

    @Autowired
    private AttrService attrService;

    @Autowired
    private UserService userService;

    public static String name = "444444";


    @Transactional(rollbackFor = Exception.class,transactionManager = "btsManagerOne")
    public void update() {
        userService.updateUser();
        attrService.updateAttr();
    }

    @Transactional(rollbackFor = Exception.class,transactionManager = "btsManagerOne")
    public void updateUser(){
        UserEntity userEntity = new UserEntity();
        userEntity.setId(1);
        userEntity.setName(name);
        userDao.updateTemplateById(userEntity);
//        getSum();
    }

    public void getSum(){
        int a = 1 / 0;
        System.out.println(a);
    }
}
